<template>
    <el-form :model="properties">
        <el-form-item label="名称" label-width="20%" prop="name">
            <el-input v-model="properties.conditionName" placeholder="名称" clearable />
        </el-form-item>

        <el-divider>数据联动</el-divider>
        <ConditionDataAssociation :rule-info="properties.condition" :variableList="formBuildList"/>
    </el-form>

</template>

<script setup name="YwuConditionChildNodeDrawer">
import {queryFlowFormInfo, queryFlowVersionFormInfo} from "@/request/flow";
import ConditionDataAssociation from "@/views/bpmn/flow/component/ConditionDataAssociation.vue";
import {computed, defineProps, ref} from "vue";

let props = defineProps(['properties', 'globalFlowInfo']);

let properties = computed(() => {return props['properties']})
let globalFlowInfo = computed(() => {return props['globalFlowInfo']})

let formBuildList = ref([])

init()
function init() {
    // 根据表单ID查询表单数据
    if (globalFlowInfo.value.status === "DRAFT") {
        // 查询草稿状态的表单数据
        queryFlowFormInfo({id: globalFlowInfo.value.id}).then(res => {
            let formJson = res.data.formJson
            // 序列化json
            let jsonInfo = JSON.parse(formJson);
            formBuildList.value = jsonInfo.componentJson
        })
    } else {
        queryFlowVersionFormInfo({
            resourceId: globalFlowInfo.value.id,
            version: globalFlowInfo.value.version
        }).then(res => {
            let formJson = res.data.formJson
            // 序列化json
            let jsonInfo = JSON.parse(formJson);
            formBuildList.value = jsonInfo.componentJson
        })
    }
}
</script>

<style scoped lang="less">

</style>